package com.ll.xiaonew.system.modules.promote.controller;

import com.ll.xiaonew.system.common.utils.PageUtils;
import com.ll.xiaonew.system.common.utils.R;
import com.ll.xiaonew.system.modules.promote.entity.HomePromoteBean;
import com.ll.xiaonew.system.modules.promote.service.HomePromoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;



/**
 * 
 *
 * @author new
 * @email new@qq.com
 * @date 2022-08-10 19:26:07
 */
@RestController
@RequestMapping("/promote")
public class HomePromoteController {
    @Autowired
    private HomePromoteService homePromoteService;

    /**
     * 列表
     */
    @GetMapping("/findCurrentDay")
    public HomePromoteBean findCurrentDay(){
        return homePromoteService.findCurrentDay();
    }

    @RequestMapping("/list")
//    @RequiresPermissions("promote:homeprompte:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = homePromoteService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("promote:homeprompte:info")
    public R info(@PathVariable("id") Integer id){
		HomePromoteBean homePrompte = homePromoteService.getById(id);

        return R.ok().put("homePrompte", homePrompte);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("promote:homeprompte:save")
    public R save(@RequestBody HomePromoteBean homePrompte){
        homePrompte.setCreateTime(new Date());
		homePromoteService.save(homePrompte);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("promote:homeprompte:update")
    public R update(@RequestBody HomePromoteBean homePrompte){
		homePromoteService.updateById(homePrompte);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("promote:homeprompte:delete")
    public R delete(@RequestBody Integer[] ids){
		homePromoteService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
